﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using Bangle.Model;

namespace Bangle.BLL
{
    //T_Phone
    public partial class T_SaleBLL
    {
        /// <summary>
        /// 获取销售单号流水号
        /// </summary>
        public string GetNewSaleCode(string BaseCode, int len)
        {
            string swhere = BaseCode;
            for (int i = 0; i < len; i++)
            {
                swhere += "[0-9]";
            }
            string sMaxSaleCode = dal.GetMaxSaleCode(swhere);
            string sResult = "";

            int BaseNum = 10;
            for (int i = 0; i < len; i++)
            {
                BaseNum = BaseNum * 10;
            }
            if (sMaxSaleCode == "")
            {

                sResult = BaseCode + ((BaseNum + 1).ToString().Substring(2));
            }
            else
            {
                //截取数字
                int iNewNum = Convert.ToInt32(sMaxSaleCode.Substring(BaseCode.Length));
                sResult = BaseCode + ((BaseNum + iNewNum + 1).ToString().Substring(2));
            }
            return sResult;
        }
    }
}